﻿using System;

namespace Callisto.Infrastructure
{
    public class RepositoryBase<TItem, TDetail> : IRepository<TItem>, IDetailRepository<TDetail>
        where TItem : class
        where TDetail : class
    {
        #region Methods
        public IObservable<TItem> Get(Guid id)
        {
            throw new NotImplementedException();
        }

        public IObservable<TItem> GetList()
        {
            throw new NotImplementedException();
        }

        IObservable<object> IRepository.Get(Guid id)
        {
            return this.Get(id);
        }

        IObservable<object> IRepository.GetList()
        {
            return this.GetList();
        }

        public void Delete(Guid id)
        {
            throw new NotImplementedException();
        }

        public IObservable<TDetail> GetDetail()
        {
            throw new NotImplementedException();
        }

        public IObservable<TDetail> GetDetail(Guid id)
        {
            throw new NotImplementedException();
        }

        public void Save(TDetail obj)
        {
            throw new NotImplementedException();
        }

        IObservable<object> IDetailRepository.GetDetail()
        {
            return this.GetDetail();
        }

        IObservable<object> IDetailRepository.GetDetail(Guid id)
        {
            return this.GetDetail(id);
        }

        public void Save(object obj)
        {
            throw new NotImplementedException();
        }
        #endregion Methods
    }

    public class RepositoryBase<TItem, TDetail, TContext> : RepositoryBase<TItem, TDetail>
        where TItem : class
        where TDetail : class
    {
        #region Properties
        private readonly TContext _context;
        public TContext Context
        {
            get { return _context; }
        }
        #endregion Properties

        #region Ctor
        public RepositoryBase(TContext context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            _context = context;
        }
        #endregion Ctor
    }
}